Page({
  data: {
    pageIndex: 1,
    loading: false,
    noMore: false,
    list: null,
    type: require('../../config/enum')['feedback'],
    group: require('../../config/enum')['sourceGroup']
  },
  onLoad: function () {
    this.myFeedback();
  },
  onPageScroll: function (e) {
    this.setData({
      scrollTop: e.scrollTop
    });
  },
  onReachBottom: function () {
    if (this.data.noMore) return;
    this.myFeedback();
  },
  myFeedback: function () {
    wx.util.request('user.feekback.list').then(feedback => {
      for (let item of feedback) {
        item.date = wx.time.toDate(item.created_at);
      }
      this.setData({
        list: feedback,
        loading: false,
        noMore: feedback.length < 10,
        pageIndex: this.data.pageIndex + 1
      });
    });
  },
  detail: function (e) {
    wx.navigateTo({
      url: `detail?id=${e.currentTarget.dataset.id}`,
    })
  }
})